package com.gzk.oeno.business.vin;

import java.util.Map;
import java.util.Set;

import com.gzk.oeno.business.IFriendlyNamed;
import com.gzk.oeno.business.INamed;
import com.gzk.oeno.business.appellation.Appellation;
import com.gzk.oeno.business.cepage.Cepage;
import com.gzk.oeno.business.codif.CodifVin;
import com.gzk.oeno.business.opinion.Opinion;
import com.gzk.oeno.business.pays.Pays;
import com.gzk.oeno.business.recompense.Recompense;
import com.gzk.oeno.business.terroir.Terroir;
import com.gzk.oeno.business.typevin.TypeVin;
import com.gzk.utils.data.IdObject;

public class Vin implements IdObject<Integer>, INamed, IFriendlyNamed{

	private Integer id;
	private String name;
	private TypeVin type;
	private Pays pays;
	private Terroir terroir;
	private Appellation appellation;
	private Integer millesime;
	private String producteur;
	private String autresMentions;
	
	private Map<Recompense, Integer> recompenses;
	private Map<Cepage, Float> composition;
	private Map<CodifVin, String> codes;
	private Set<Lien> liens;
	private Set<Prix> prix;
	private Set<Opinion> opinions;
	
	public Vin(){}
	

	public void setName(String name) {
		this.name = name;
	}

	public void setType(TypeVin type) {
		this.type = type;
	}

	public void setPays(Pays pays) {
		this.pays = pays;
	}

	public void setTerroir(Terroir terroir) {
		this.terroir = terroir;
	}

	public void setAppellation(Appellation appellation) {
		this.appellation = appellation;
	}

	public void setMillesime(Integer millesime) {
		this.millesime = millesime;
	}

	public void setProducteur(String producteur) {
		this.producteur = producteur;
	}

	public void setAutresMentions(String autresMentions) {
		this.autresMentions = autresMentions;
	}

	public void setRecompenses(Map<Recompense, Integer> recompenses) {
		this.recompenses = recompenses;
	}

	public void setComposition(Map<Cepage, Float> composition) {
		this.composition = composition;
	}

	public void setCodes(Map<CodifVin, String> codes) {
		this.codes = codes;
	}

	public void setLiens(Set<Lien> liens) {
		this.liens = liens;
	}

	public void setPrix(Set<Prix> prix) {
		this.prix = prix;
	}

	public TypeVin getType() {
		return type;
	}

	public Pays getPays() {
		return pays;
	}

	public Terroir getTerroir() {
		return terroir;
	}

	public Appellation getAppellation() {
		return appellation;
	}

	public Integer getMillesime() {
		return millesime;
	}

	public String getProducteur() {
		return producteur;
	}

	public String getAutresMentions() {
		return autresMentions;
	}

	public String getName() {
		return name;
	}
	
	public Map<Recompense, Integer> getRecompenses() {
		return recompenses;
	}

	public Map<Cepage, Float> getComposition() {
		return composition;
	}

	public Map<CodifVin, String> getCodes() {
		return codes;
	}

	public Set<Lien> getLiens() {
		return liens;
	}

	public Set<Prix> getPrix() {
		return prix;
	}

	public Set<Opinion> getOpinions() {
		return opinions;
	}


	public void setOpinions(Set<Opinion> opinions) {
		this.opinions = opinions;
	}


	@Override
	public Integer getId() {
		return id;
	}

	@Override
	public void setId(Integer key) {
		this.id = key;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Vin other = (Vin) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	@Override
	public String getFriendlyName() {
		StringBuilder sb = new StringBuilder(name);
		if (millesime != null){
			sb.append(" ").append(millesime.toString());
		}
		sb.append(" (");
		if (terroir != null){
			sb.append(terroir.getName()).append(" / ");
		}
		sb.append(pays.getName()).append(")");
		return sb.toString();
	}


}
